<template>
  <div class="home">
    <img alt="Vue logo" src="../assets/logo.png" />
    <HelloWorld msg="Welcome to Your Vue.js App" />
  </div>
</template>

<script>
import api from "@/api";
// import axios from "axios";
// @ is an alias to /src
import HelloWorld from "@/components/HelloWorld.vue";

export default {
  name: "HomeView",
  components: {
    HelloWorld,
  },
  mounted() {
    //api的get带参请求-------------
    // getThird({
    //   name: "李强",
    //   age: 18,
    // })
    //   .then((res) => {
    //     console.log("res", res);
    //   })
    //   .catch((err) => {
    //     console.log("err", err);
    //   });
    //api的get请求设置跨域------------------------
    // axios
    //   .get("http://localhost:8080/redirect")
    //   .then((res) => {
    //     console.log("/7788", res);
    //   })
    //   .catch((err) => {
    //     console.log("err", err);
    //   });
    //api的post请求--------------
    api.test
      .getFourth({
        name: "Jack",
        age: 20,
      })
      .then((res) => {
        console.log("res", res);
      })
      .catch((err) => {
        console.log("err", err);
      });
  },
};
</script>
<style scoped lang="scss">
img {
  display: block;
  width: 200px;
  height: 200px;
  margin: 0 auto;
}
</style>
